package alertOperate

import (
	"context"
	"devops-super/api/alerts/v1"
	"devops-super/internal/service"
)

// GetSceneListByPeople 根据联系人ID获取关联的告警场景列表
func (*ControllerV1) GetSceneListByPeople(ctx context.Context, req *v1.GetSceneListByPeopleReq) (res *v1.GetSceneListByPeopleRes, err error) {
	res = &v1.GetSceneListByPeopleRes{}
	res.Scenes, err = service.AlertOperate().GetSceneListByPeople(ctx, req.PeopleId)
	return
}

// SetPeopleSceneRel 设置联系人关联的告警场景
func (*ControllerV1) SetPeopleSceneRel(ctx context.Context, req *v1.SetPeopleSceneRelReq) (res *v1.SetPeopleSceneRelRes, err error) {
	err = service.AlertOperate().SetPeopleSceneRel(ctx, req.PeopleId, req.SceneIds)
	return
}

// GetPeopleListByScene 根据场景ID获取关联的联系人列表
func (*ControllerV1) GetPeopleListByScene(ctx context.Context, req *v1.GetPeopleListBySceneReq) (res *v1.GetPeopleListBySceneRes, err error) {
	res = &v1.GetPeopleListBySceneRes{}
	res.People, err = service.AlertOperate().GetPeopleListByScene(ctx, req.SceneId)
	return
}

// SetScenePeopleRel 设置场景关联的联系人
func (*ControllerV1) SetScenePeopleRel(ctx context.Context, req *v1.SetScenePeopleRelReq) (res *v1.SetScenePeopleRelRes, err error) {
	err = service.AlertOperate().SetScenePeopleRel(ctx, req.SceneId, req.PeopleIds)
	return
}

// GetSceneListByDevice 根据设备ID获取关联的告警场景列表
func (*ControllerV1) GetSceneListByDevice(ctx context.Context, req *v1.GetSceneListByDeviceReq) (res *v1.GetSceneListByDeviceRes, err error) {
	res = &v1.GetSceneListByDeviceRes{}
	res.Scenes, err = service.AlertOperate().GetSceneListByDevice(ctx, req.DeviceNo)
	return
}

// SetDeviceSceneRel 设置设备关联的告警场景
func (*ControllerV1) SetDeviceSceneRel(ctx context.Context, req *v1.SetDeviceSceneRelReq) (res *v1.SetDeviceSceneRelRes, err error) {
	err = service.AlertOperate().SetDeviceSceneRel(ctx, req.DeviceNo, req.SceneIds)
	return
}

// GetDeviceListByScene 根据场景ID获取关联的设备列表
func (*ControllerV1) GetDeviceListByScene(ctx context.Context, req *v1.GetDeviceListBySceneReq) (res *v1.GetDeviceListBySceneRes, err error) {
	res = &v1.GetDeviceListBySceneRes{}
	res.Devices, err = service.AlertOperate().GetDeviceListByScene(ctx, req.SceneId)
	return
}

// SetSceneDeviceRel 设置场景关联的设备
func (*ControllerV1) SetSceneDeviceRel(ctx context.Context, req *v1.SetSceneDeviceRelReq) (res *v1.SetSceneDeviceRelRes, err error) {
	err = service.AlertOperate().SetSceneDeviceRel(ctx, req.SceneId, req.DeviceNos)
	return
}

// GetSceneListByDeviceGroup 根据设备分组ID获取关联的告警场景列表
func (*ControllerV1) GetSceneListByDeviceGroup(ctx context.Context, req *v1.GetSceneListByDeviceGroupReq) (res *v1.GetSceneListByDeviceGroupRes, err error) {
	res = &v1.GetSceneListByDeviceGroupRes{}
	res.Scenes, err = service.AlertOperate().GetSceneListByDeviceGroup(ctx, req.DeviceGroupId)
	return
}

// SetDeviceGroupSceneRel 设置设备分组关联的告警场景
func (*ControllerV1) SetDeviceGroupSceneRel(ctx context.Context, req *v1.SetDeviceGroupSceneRelReq) (res *v1.SetDeviceGroupSceneRelRes, err error) {
	err = service.AlertOperate().SetDeviceGroupSceneRel(ctx, req.DeviceGroupId, req.SceneIds)
	return
}

// GetDeviceGroupListByScene 根据场景ID获取关联的设备分组列表
func (*ControllerV1) GetDeviceGroupListByScene(ctx context.Context, req *v1.GetDeviceGroupListBySceneReq) (res *v1.GetDeviceGroupListBySceneRes, err error) {
	res = &v1.GetDeviceGroupListBySceneRes{}
	res.DeviceGroups, err = service.AlertOperate().GetDeviceGroupListByScene(ctx, req.SceneId)
	return
}

// SetSceneDeviceGroupRel 设置场景关联的设备分组
func (*ControllerV1) SetSceneDeviceGroupRel(ctx context.Context, req *v1.SetSceneDeviceGroupRelReq) (res *v1.SetSceneDeviceGroupRelRes, err error) {
	err = service.AlertOperate().SetSceneDeviceGroupRel(ctx, req.SceneId, req.DeviceGroupIds)
	return
}
